package com.mobile.liuyi_s.orderlunch.Utils;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;

import com.mobile.liuyi_s.orderlunch.entity.MyUser;
import com.mobile.liuyi_s.orderlunch.entity.Order;

import java.util.ArrayList;
import java.util.List;

import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;
import cn.bmob.v3.listener.SaveListener;

/**
 * Created by liuyi_s on 2017/7/26 13:17.
 * Email：liuyi_s@foxmail.com
 */


/***
 * use BmobUser.signup() replace this method
 */
public class UserUtils {
    private static final String TAG = "UserUtils";
    private boolean isSigned;

    public boolean signUp(final Context context, String userName, String userPwd) {
        if (userName.length() > 0 && userPwd.length() > 0) {
            MyUser user = new MyUser();
//            user.setUserName(userName);
//            user.setUserPwd(userPwd);
            user.save(new SaveListener<String>() {
                @Override
                public void done(String objectID, BmobException e) {
                    if (e == null) {
                        isSigned = true;
                        Toast.makeText(context, "注册成功", Toast.LENGTH_SHORT).show();
                    } else {
                        isSigned = false;
                        Toast.makeText(context, "注册失败", Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }
        return isSigned;
    }


}
